const Router = require('koa-router');
const router = new Router();
const studentController = require('../controllers/student.controller');
const authMiddleware = require('../middlewares/auth.middleware');

// 学生相关API路由

// 获取所有学生列表
router.get('/', authMiddleware.authenticateToken, studentController.getAllStudents);

// 获取单个学生信息
router.get('/:id', authMiddleware.authenticateToken, studentController.getStudentById);

// 创建新学生
router.post('/', authMiddleware.authenticateToken, authMiddleware.authorize(['admin', 'teacher']), studentController.createStudent);

// 更新学生信息
router.put('/:id', authMiddleware.authenticateToken, authMiddleware.authorize(['admin', 'teacher']), studentController.updateStudent);

// 删除学生
router.delete('/:id', authMiddleware.authenticateToken, authMiddleware.authorize(['admin']), studentController.deleteStudent);

// 分页获取学生列表
router.get('/paginated/list', authMiddleware.authenticateToken, studentController.getStudentsPaginated);

// 根据班级获取学生列表
router.get('/by-class/:classId', authMiddleware.authenticateToken, studentController.getStudentsByClass);

// 根据宿舍获取学生列表
router.get('/by-dormitory/:dormitoryId', authMiddleware.authenticateToken, studentController.getStudentsByDormitory);

module.exports = router;